package com.example._01_jax_ws_server;


import com.example._01_jax_ws_server.service.HelloService;
import com.example._01_jax_ws_server.service.impl.HelloServiceImpl;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

public class Server {
    public static void main(String[] args) {
        //  发布服务的工厂
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();

        String address = "http://localhost:8000/ws/hello";
        address = "http://127.0.0.1:8088/tdata-sync/services/SapOrderMains?wsdl";
        //  设置服务地址
        factory.setAddress(address);

        //  设置服务类
        factory.setServiceBean(new HelloServiceImpl());
        factory.setServiceClass(HelloService.class);
        //  添加日志输入、输出拦截器，观察soap请求、soap响应内容
        factory.getInInterceptors().add(new LoggingInInterceptor());
        factory.getOutInterceptors().add(new LoggingOutInterceptor());

        //  发布服务
        HelloService helloService = (HelloService) factory.create();
        helloService.sayHello("222");
        System.out.println("发布服务成功，端口8000.....");
        System.out.println("wsdl地址:" + address + "?wsdl");

    }
}
